<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
<%@ include file="/common/common-css.v2.jsp"%>
<style>
#jquery-table td {
	cursor: pointer !important;
	word-break: break-all;
	word-wrap: break-word;
}

.load_bg {
	background: #000;
	opacity: 0.1;
	left: 0px;
	top: 0px;
	position: fixed;
	height: 100%;
	width: 100%;
	overflow: hidden;
	z-index: 10000;
}

.load_img {
	left: 50%;
	top: 180px;
	position: fixed;
	height: 50px;
	overflow: hidden;
	z-index: 20000;
}

a.check {
	margin-bottom: 10px;
}

@media ( min-width : 768px) and (max-width: 1200px) {
	.backup-text {
		width: 100px !important;
	}
}
</style>
</head>
<body class="no-skin">
	<div class="load_bg" style="display: none;"></div>
	<img src="http://img.tuanzidai.cn/commentloading.gif" class="load_img"
		style="display: none" />
	<div class="page-content">
		<div id="test"></div>
		<form id="queryForm" action="" method="POST">
			<div class="page-content-area">
				<div class="row">
					<div class="col-sm-12">
						<div class="widget-box"
							style="border: 0px solid #ccc; border-top: none; border-bottom: none;margin-top:15px;">
							<div class="widget-header widget-header-blue widget-header-flat">
								<h4 class="widget-title">选择条件进行查询</h4>

								<div class="widget-toolbar">
									<a href="#" data-action="collapse"> <i
										class="ace-icon fa fa-chevron-up"></i>
									</a>
								</div>
							</div>

							<div class=" widget-body">
							
								<div class="widget-main" id="condition">
								
								    <div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">活动ID：</label>
										<div class="col-sm-8" style="padding-left: 0;">
										<select id="activityId" name="activityId" class="form-control"></select> 
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">活动名称：</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select id="activityName" name="activityName" class="form-control"></select>  
											
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">用户手机号：</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<input type="text" name="mobnum" style="width: 100%; text-align: left;">
										</div>
									</div>
									
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">登录状态：</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select name="status" class="form-control">
												<option value="">---请选择---</option>
												<option value="1">成功登录</option>
												<option value="0">验证失败</option>
											</select>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">平台:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select class="form-control" name="platform">
												<option value="">全部</option>
												<option value="0">通用</option>
												<option value="android">安卓</option>
												<option value="ios">ios</option>
											</select>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">产品：</label>
										<div class="col-sm-8" style="padding-left: 0;">				
										<select id="prdid" name="prdid" class="form-control"></select>  
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label" for="isprize"
										style="text-align: right">登录时间：</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<div class="input-daterange input-group">
												<input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="startTime" name="startTime"> 
												 <span class="input-group-addon" style="width: 6px"> 
												    <i class="fa fa-exchange"></i>
												 </span>
												 <input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="endTime" name="endTime">
											 </div>
										</div>
									</div>
									
									
								</div>
							</div>
						</div>
					</div>
					<div class="col-md-12 center">
						<div class="clearfix form-actions myaction">

							<button class="btn btn-purple  no-border" type="button"
								name="btn-query" onclick="query_any()">
								<i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
								查询
							</button>
							&nbsp;&nbsp;&nbsp;
							<button class="btn btn-grey no-border" type="reset">
								<i class="ace-icon fa fa-undo icon-on-right bigger-110"></i> 重置
							</button>
						</div>
					</div>
				</div>
				
				<div class="row">
					<div class="col-xs-12">
					    <a href="javascript:void(0)" class="btn btn-success btn-small"
					      id="output" style="display: none;" onclick="loadlist()">导出列表</a>
						<table id="jquery-table"
							class="table table-striped table-bordered table-hover">
						</table>
					</div>
				</div>
			</div>
		</form>
	</div>
<%@ include file="/common/common-js.jsp"%>
<script type="text/javascript" src="${ctx}/js/call_func.js"></script>


<script type="text/javascript">

	//选择项活动ID
	function loadActivityId(){
		$.ajax({
			type : 'POST',
			dataType : 'json',
			url : ctx + "/getQueryCondition/getActivityUnionTypeIsNull.action?rand="
					+ Math.random(),
			timeout : 300000,
			success : function(resp) {
				var data = resp["aaData"];
				var activityId = '<option value="">请选择</option>';
				
				for (var i = 0; i < data.length; i++) {
					activityId += '<option value="' + data[i]["activityId"] + '">'
							+ data[i]["activityId"] + '</option>';
				}
				$("#activityId").html(activityId);
			},
		});
	}
	
	//选择项活动ID
	function loadActivityName(){
		$.ajax({
			type : 'POST',
			dataType : 'json',
			url : ctx + "/getQueryCondition/getActivityUnionTypeIsNull.action?rand="
					+ Math.random(),
			timeout : 300000,
			success : function(resp) {
				var data = resp["aaData"];
				var activityName = '<option value="">请选择</option>';
				
				for (var i = 0; i < data.length; i++) {
					activityName += '<option value="' + data[i]["activityName"] + '">'
							+ data[i]["activityName"] + '</option>';
				}
				$("#activityName").html(activityName);
			},
		});
	}


	//导出列表
	function loadlist() {
		var form = document.forms["queryForm"];
		form.action = ctx + "/loanApiRecord/exportData.action";
		form.submit();
	}
	
	//【查询】按钮Click事件
	function query_any() {
		$("#output").show();
		if(jqTable != null){
			jqTable.fnDraw();
		} else{
			loaddata();
		}
	}
    
	var jqTable = null;
	var loaddata = function() {
		jQuery(function($) {
			jqTable = $('#jquery-table').dataTable({
				//数据列控制（包括对应返回JSON属性名称，对应表头列索引位置、数据转换封装等）
				
				//strSql.append("select a.source_id, b.name AS source_name,a.mobnum,a.ctime, a.platform,c.name AS product_name,d.channel_name,a.result ");
				
				"columnDefs" : [
						{
							"title" : '活动ID',
							"targets" : [ 0 ],
							"data" : "source_id",
							"class" : "center",
							"bSortable" : false,
							"width" : "100px",
						},
						{
							"title" : '合作方',
							"targets" : [ 1 ],
							"data" : "source_name",
							"class" : "center",
							"bSortable" : false,
							"width" : "200px",
						},
						{
							"title" : '手机号',
							"targets" : [ 2 ],
							"data" : "mobnum",
							"class" : "center",
							"bSortable" : false,
							"width" : "200px",
						},
						{
							"title" : '姓名',
							"targets" : [ 3 ],
							"data" : "petname",
							"class" : "center",
							"bSortable" : false,
							"width" : "150px",
						},
						{
							"title" : '登录时间',
							"targets" : [ 4 ],
							"data" : "ctime",
							"class" : "center",
							"bSortable" : false,
							"width" : "200px",
						},
						{
							"title" : '平台',
							"targets" : [ 5 ],
							"data" : "platform",
							"class" : "center",
							"bSortable" : false,
							"width" : "150px",
						},
						{
							"title" : '产品',
							"targets" : [ 6 ],
							"data" : "product_name",
							"class" : "center",
							"bSortable" : false,
							"width" : "200px",
						},
						{
							"title" : '渠道',
							"targets" : [ 7 ],
							"data" : "channel_name",
							"class" : "center",
							"bSortable" : false,
						},
						{
							"title" : '状态',
							"targets" : [ 8 ],
							"data" : "result",
							"class" : "center",
							"bSortable" : false,
							"width" : "150px",
							"render": function(value, type, row) {
								switch (row.result) {
								case 0:
									var temp = "验证失败";
									break;
								case 1:
									var temp = "成功登录";
									break;
								default:
									var temp = "--";
								    break;
								}
								return temp;
							}
						},
				 ],
				 "sAjaxSource": ctx + "/loanApiRecord/list.action?rand=" + Math.random(),//数据源URL
				 "fnServerData" : function(sSource, aoData,fnCallback) {
					  var data = $('#queryForm').serializeObject();
					  data.aoData = JSON.stringify(aoData);
					  $.ajax({
							"type" : "POST",
							"dataType" : 'json',
							"url" : sSource,
							"data" : data,
							"success" : function(resp) {
								fnCallback(resp);
								initListPage();
							},
							"error" : function(XMLHttpRequest,
									textStatus, errorThrown) {
							},
							"complete" : function() {
								$(".load_bg,.load_img").hide();
							}
						});
				},
				"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
	  				//=====================这里实现行双击事件======================//
	  				$(nRow).on('click', 'td .infoID', function (index) {
	  					var id = $(this).val();
						var url = "/loanuser/getinfo.action?userid=" + id;
						url = encodeURI(url);
						openDialogWithRand(url,900,996,"",function(data){
							query_any();
						});
				     });
	  			},
				"sScrollXInner" : "100%",
				"sScrollY" : "100%",//如果不设置，IE会有问题
				"aaSorting" : [ [ 0, "asc" ] ] //初始化加载，默认按第几列排序、排序方式（列从0开始计算）
			});
		});
	}
	
	//时间控件
	jQuery(function($) {
		$(".date-picker").datepicker({
			autoclose : true
		}).next().on(ace.click_event, function() {
			$(this).prev().focus();
		});
	});
	
	$(document).ready(function(){
	//	loadChannel();
		loadProduct();
		loadActivityId();
		loadActivityName();
    	$("#activityId").combobox();
		$("#activityName").combobox();
	//	$("#channel").combobox();
	//	$("#prdid").combobox();
	});
</script>

</body>
</html>